csv: decompose UTF to the Queen's Original ASCII.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 1 Mar 2004 02:29:23 +0000 (02:29 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 1 Mar 2004 02:29:23 +0000 (02:29 +0000)
util: add case for ellipsis decoding.

gpsbabel/csv_util.c
gpsbabel/util.c

index c095d7e514142667fe7ae154127225bcde7615ce..af1396d68c51ef3f48a7c155b449c51f2b447dd5 100644 (file)
@@ -641,6 +641,12 @@ xcsv_waypt_pr(const waypoint *wpt)
            description = shortname;
     }
 
+    if (description) {
+           char *odesc = description;
+           description = str_utf8_to_ascii(odesc);
+           xfree(odesc);
+    }
+
     i = 0;
     QUEUE_FOR_EACH(xcsv_file.ofield, elem, tmp) {
         fmp = (field_map_t *) elem;
index bbdc53fbff8e5fa5c5f9cc0ec2048f3dc1832151..8ac7d26c8d3327214074405a5552d4cc3764e113 100644 (file)
@@ -708,9 +708,10 @@ char * str_utf8_to_ascii( const char * str )
                if ( *cur & 0x80 ) {
                        int bytes;
                        int value;
+                       char *strvalue = "";
                        utf8_to_int( cur, &bytes, &value );
-
                        switch (value) {
+                               case 0x2026: strvalue = "..."; break;
                                case 0x201c: value = '\"'; break;
                                case 0x201d: value = '\"'; break;
                                case 0xb4:
@@ -745,8 +746,13 @@ char * str_utf8_to_ascii( const char * str )
                                case 0xf8: value = '0'; break;
                                default: value='?'; break;;
                        }
-                       *cur = (char)value;
-                       strcpy( cur+1, cur+bytes );
+                       if (strvalue) {
+                               memcpy(cur, strvalue, bytes);
+                               cur += bytes - 1;
+                       } else {
+                               *cur = (char)value;
+                               strcpy( cur+1, cur+bytes );
+                       }
                }
                cur++;
        }